package com.note.common.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 标签实体类
 * 对应数据库tag表，用于笔记标签分类
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("tag")
@Schema(description = "标签实体")
public class Tag extends BaseEntity {

    /**
     * 标签ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "标签ID", example = "1")
    private Long id;

    /**
     * 标签名称
     */
    @TableField("name")
    @Schema(description = "标签名称", example = "Java")
    private String name;

    /**
     * 所属用户ID
     */
    @TableField("user_id")
    @Schema(description = "所属用户ID", example = "1")
    private Long userId;


    @TableField
    @Schema(description = "删除标记 0:正常 1:删除", example = "0")
    private Integer deleted = 0;

    @Column(name = "created_at")

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2023-10-01T12:00:00")
    private LocalDateTime createdAt;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @Column(name = "updated_at")
    @Schema(description = "更新时间", example = "2023-10-01T12:00:00")
    private LocalDateTime updatedAt;
} 